<template>
  <div>
    <div>
      <!-- 二级路由出口 -->
     <router-view></router-view>
      <keep-alive include="Menu"></keep-alive>
    </div>
    <van-tabbar
      v-model="active"
      active-color="#0C34BA"
      inactive-color="#646566"
      route
    >
      <!-- icon="home-o" -->
      <van-tabbar-item
        v-for="(item, index) in itemNav"
        :key="index"
        :to="item.to"
      >
        <span>{{ item.title }}</span>
        <template #icon="props">
          <img
            :src="props.active ? item.icon.activeIcon : item.icon.inactiveIcon"
          />
        </template>
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  name: "Main",
  data() {
    return {
      active: 0,
      itemNav: [
        {
          title: "首页",
          icon: {
            activeIcon: require("../assets/images/home_active.png"),
            inactiveIcon: require("../assets/images/home.png"),
          },
          to: { name: "Home" },
        },
        {
          title: "菜单栏",
          icon: {
            activeIcon: require("../assets/images/menu_active.png"),
            inactiveIcon: require("../assets/images/menu.png"),
          },
          to: { name: "Menu" },
        },
        {
          title: "购物车",
          icon: {
            activeIcon: require("../assets/images/shopbag_active.png"),
            inactiveIcon: require("../assets/images/shopbag.png"),
          },
          to: { name: "Shopbag" },
        },
        {
          title: "我的",
          icon: {
            activeIcon: require("../assets/images/my_active.png"),
            inactiveIcon: require("../assets/images/my.png"),
          },
          to: { name: "My" },
        },
      ],
    };
  },
  created() {
    
  },
  updated() {
    
  },
};
</script>

<style lang="scss" scoped>
</style>